﻿using System.Collections.Generic;
namespace SqlAnalysis
{
    public enum SQLAction
    {
        SELECT, UPDATE, INSERT, DELETE, CONDITION, Other
    }
    public class AnalysisOptions : OptionBase
    {
        public int Top { get; set; }
        public string Value { get; set; }
        public bool IsDistinct { get; set; }
        public SortBy OrderBy { get; set; }
        public Group GroupBy { get; set; }
        public Dictionary<string, string> AliasTableMap { get; set; }
        public SQLAction Action { get; set; }

        public List<JoinOption> JoinOptions { get; set; }

    }
    public class Group
    {
        public string[] Fields { get; set; }
        public List<ConditionGroup> Wheres { get; set; }
    }

    public class SortBy
    {
        public string[] Fields { get; set; }
        public string OrderType { get; set; }
    }

    public class JoinOption : OptionBase
    {
        public string JoinType { get; set; }
    }
    public class OptionBase
    {
        public string Alias { get; set; }
        public string TableName { get; set; }
        public bool IsScope { get; set; }
        public string[] Fields { get; set; }
        public List<ConditionGroup> Wheres { get; set; }
    }

    public class Condition
    {
        public bool IsLeftScope { get; set; }
        public string LeftScope { get; set; }
        public string LeftFN { get; set; }
        public string LeftAlias { get; set; }
        public string LeftField { get; set; }
        public bool IsRightScope { get; set; }
        public string RightScope { get; set; }
        public string RightFN { get; set; }
        public string RightAlias { get; set; }
        public string RightField { get; set; }
        public string RightAlias2 { get; set; }
        public string RightField2 { get; set; }
        public string Logic { get; set; }
        public string Value { get; set; }
    }
    public class ConditionGroup
    {
        public List<ConditionGroup> ConditionGroups { get; set; }
        public List<Condition> Conditions { get; set; } = new List<Condition>();
    }

}